package com.special.requirement.shape;

/**
 * @author liuYC
 * @ClassName Animal
 * @Description TODO
 * @date 2021/5/6 17:17
 */

abstract class Animal {
    String name;
    static String color = "动物色";

    public Animal(String name) {
        this.name = name;
    }

    public abstract void run();

    public void eat() {
        System.out.println("动物在吃东西");
    }
}

//老鼠
class Mouse extends Animal {
    static String color = "老鼠色";

    public Mouse(String name) {
        super(name);
    }

    public void run() {
        System.out.println(name + "四条腿，灵活的走位");
    }

    public void eat() {
        System.out.println("老鼠在吃东西");
    }

    public void dig() {//老鼠特有的方法
        System.out.println("老鼠在打洞");
    }
}

class Fish extends Animal {
    public Fish(String name) {
        super(name);
    }

    public void run() {
        System.out.println(name + "在海中快速的游行");
    }
}

public class Demo4 {//多态

    public static void main(String[] args) {
        Animal a = new Mouse("老鼠");
//        访问父类的属性；
        System.out.println(a.color);
//        在同名非静态函数时才是访问子类的。
        a.eat();
        a.run();
    }
}
